﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SKYPE4COMLib;

namespace SouslikPod.Wrappers
{
    public class SkypeWrapper
    {
        private static SkypeWrapper _intstance;
        private readonly SkypeClass _skypeInternal;

        private SkypeWrapper()
        {
            _skypeInternal = new SkypeClass();
            if (!_skypeInternal.Client.IsRunning)
            {
                _skypeInternal.Client.Start(true, true);
            }
   
        }

        public static SkypeWrapper GetSkype()
        {
            if(_intstance == null )
            {
                _intstance = new SkypeWrapper();
            }

            return _intstance;
        }

        public Chat GetChat(string name)
        {
            return _skypeInternal.get_Chat(name);
        }

        public void SendMessage(string message)
        {
            _skypeInternal.SendMessage(_skypeInternal.CurrentUser.Handle, message);
        }

        public ChatCollection GetChats()
        {
            return _skypeInternal.RecentChats;
        }

        public void AttachToMessageEvent(_ISkypeEvents_MessageStatusEventHandler handler)
        {
            _skypeInternal.MessageStatus += handler;
        }
         

        public string Info
        {
            get
            {
                return String.Format("NickName: {0}",_skypeInternal.CurrentUser.Handle);
            }
        }
    }
}
